package com.paso.springbootsecurity.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @Classname: SpringDataUserDetailsService
 * @Description: 定义用户信息服务（查询用户信息）
 * @Date: 2021/2/22 19:33
 * @Created: by Wang Xu
 */
@Service
public class SpringDataUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        // 将来连接数据库根据账号查询用户信息
        // 模拟
        System.out.println(username);

        return User
                .withUsername("zhangsan")
                .password("$2a$10$fX03gRdbC.a5pvNETWbVR.Gc3thqgnfScOw86BkcAFPxRk3NfBdO6")
                .authorities("p1")
                .build();

    }
}
